#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 crane <crane@his-pc>
#
# Distributed under terms of the MIT license.

"""

"""


class Solution:
    """
    @param: nums: Given an integers array A
    @return: A long long array B and B[i]= A[0] * ... * A[i-1] * A[i+1] * ... * A[n-1]
    """
    def productExcludeItself(self, nums):
        # write your code here
        n = len(nums)
        left_accu = [None] * len(nums)
        left_accu[0] = 1
        left, right = 1, 1

        for i in range(1, n):
            left *= nums[i-1]
            left_accu[i] = left

        # n-2 ------> 0
        for i in range(n-2, -1, -1):
            right *= nums[i+1]
            left_accu[i] *= right

        return left_accu


def main():
    print("start main")
    s = Solution()
    r = s.productExcludeItself([1,2,3, 4])
    print(r)

if __name__ == "__main__":
    main()
